package cn.middle.remote.server;

import cn.middle.remote.handler.netty.BaseHandler;
import cn.middle.remote.message.BaseSignal;
import io.netty.channel.ChannelHandlerContext;

public class ServerHandler extends BaseHandler<BaseSignal> {
	
	private ServerProcessingHandler handler;
	
	
	public ServerHandler(ServerProcessingHandler handler) {
		this.handler = handler;
	}
	
	
	/**
	 * 激活
	 */
	@Override
	public void channelActive(ChannelHandlerContext ctx) throws Exception {
		handler.channelActive(ctx);
	}
	
	/**
	 * 断开
	 */
	@Override
	public void channelInactive(ChannelHandlerContext ctx) throws Exception {
		handler.channelInactive(ctx);
	}

	@Override
	protected void channelRead0(ChannelHandlerContext ctx, BaseSignal msg) throws Exception {
		handler.received(ctx, msg);
	}
	
	/**
	 * 发生异常
	 */
	@Override
	public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
		handler.exceptionCaught(ctx, cause);
	}

}
